package com.example.paytext.controller;

import com.example.paytext.dto.PayRecordDTO;
import com.example.paytext.service.PayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/pay")
public class PayController {
    @Autowired
    private PayService payService;
    /**
     * 查询用户余额
     */
    @RequestMapping("/getUserSurMoney")
    public Map<String,Object> getUserSurMoney(@RequestParam(value = "userId") String userId){
       return payService.getUserSurMoney(userId);
    }

    /**
     * 2. 用户消费100元的接口
     * 3. 用户退款20元接口
     * @param dto
     * @return
     */
    @RequestMapping("/payMoney")
    public Map<String,Object> payMoney(PayRecordDTO dto){
        return payService.payMoney(dto);
    }
}
